home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / v cisle / hotkey / AutoHotkey104504_Install.exe / Extras / Run this to install syntax file for MED.ahk < prev    next >
Text File  |  2005-03-19  |  6KB  |  203 lines

  1. ; v0.2 by Wolfgang Reszel (Tekl)
  2.  
  3. ; set language-specific strings
  4. StringRight, Lng, A_Language, 2
  5. if Lng = 07  ; = Deutsch (0407, 0807, 0c07 ...)
  6. {
  7.    lng_close         = Bitte MED vorher schlie▀en!
  8.    lng_installed     = Die AutoHotkey-Syntax und die TextLib wurden fⁿr MED installiert.
  9.    lng_noMed         = MED ist nicht richtig installiert worden.
  10. }
  11. else        ; = other languages (english)
  12. {
  13.    lng_close         = Please close MED!
  14.    lng_installed     = The AutoHotkey-Syntax and the TextLib have been installed to MED!
  15.    lng_noMed         = MED is not properly installed.
  16. }
  17.  
  18. ; Get path where MED is installed
  19. RegRead, medpathroot, HKEY_LOCAL_MACHINE, SOFTWARE\Utopia Planitia\MED,Home
  20.  
  21. ; Set users syntax-folder
  22. medpath= %medpathroot%\med\profiles\%Username%
  23.  
  24. ; Get path of AHKs help-file
  25. ahkpath = %A_WorkingDir%
  26. StringGetPos, pos, ahkpath, \, R3
  27. StringLeft, ahkpath,ahkpath, %pos%
  28.  
  29. ; MED does not like whitespace
  30. StringReplace, ahkpath,ahkpath, %A_Space%,|
  31.  
  32. ; Checks if the syntax-folder exist
  33. IfExist, %medpath%
  34. {
  35.    ; Checks if MED is running
  36.    IfWinExist, ahk_class MRED_MAINWIN_CLASS
  37.    {
  38.       MsgBox, 48,, %lng_close%
  39.       ExitApp
  40.    }
  41.  
  42.    ; Read the header for the syntax-file
  43.    FileRead, SyntaxFile, MEDSynHeader.txt
  44.  
  45.    ; Set the path to the Helpfile
  46.    StringReplace, SyntaxFile, SyntaxFile, C:\Program|Files\AutoHotkey\, %ahkpath%\
  47.  
  48.    ; Commands
  49.    SyntaxFile = %SyntaxFile%`ncolor: darkblue, normal, black, bold
  50.    CommandCount = 0
  51.    Loop, Read, ..\Syntax\CommandNames.txt
  52.    {
  53.       IfInString, A_LoopReadLine, `;
  54.          continue
  55.       If A_LoopReadLine =
  56.          continue
  57.  
  58.       If CommandCount = 0
  59.          SyntaxFile = %SyntaxFile%`ntoken:
  60.  
  61.       StringReplace, ReadLine, A_LoopReadLine, %A_Space%, _, A
  62.  
  63.       IfInString, ReadLine, If_Else
  64.          ReadLine = If
  65.       IfInString, ReadLine, If_Var
  66.          continue
  67.       If ReadLine = Loop`,_
  68.          continue
  69.  
  70.       SyntaxFile := SyntaxFile " " ReadLine
  71.  
  72.       CommandCount++
  73.       If CommandCount > 4
  74.          CommandCount = 0
  75.    }
  76.  
  77.    ; Variables
  78.    SyntaxFile = %SyntaxFile%`n`ncolor: red, normal, black, italic
  79.    CommandCount = 0
  80.    Loop, Read, ..\Syntax\Variables.txt
  81.    {
  82.       IfInString, A_LoopReadLine, `;
  83.          continue
  84.       If A_LoopReadLine =
  85.          continue
  86.  
  87.       If CommandCount = 0
  88.          SyntaxFile = %SyntaxFile%`ntoken:
  89.  
  90.       StringReplace, ReadLine, A_LoopReadLine, %A_Space%, _, A
  91.       SyntaxFile := SyntaxFile " " ReadLine
  92.       ;SyntaxFile := SyntaxFile " %" ReadLine "%"
  93.  
  94.       CommandCount++
  95.       If CommandCount > 4
  96.          CommandCount = 0
  97.    }
  98.  
  99.    ; Keywords
  100.    SyntaxFile = %SyntaxFile%`n`ncolor: darkpink, normal, black, normal
  101.    CommandCount = 0
  102.    Loop, Read, ..\Syntax\Keywords.txt
  103.    {
  104.       IfInString, A_LoopReadLine, `;
  105.          continue
  106.       If A_LoopReadLine =
  107.          continue
  108.  
  109.       If CommandCount = 0
  110.          SyntaxFile = %SyntaxFile%`ntoken:
  111.  
  112.       StringReplace, ReadLine, A_LoopReadLine, %A_Space%, _, A
  113.       SyntaxFile := SyntaxFile " " ReadLine
  114.  
  115.       CommandCount++
  116.       If CommandCount > 4
  117.          CommandCount = 0
  118.    }
  119.  
  120.    ; Keys
  121.    SyntaxFile = %SyntaxFile%`n`ncolor: darkgreen, normal, black, underline
  122.    CommandCount = 0
  123.    Loop, Read, ..\Syntax\Keys.txt
  124.    {
  125.       IfInString, A_LoopReadLine, `;
  126.          continue
  127.       If A_LoopReadLine =
  128.          continue
  129.  
  130.       If CommandCount = 0
  131.          SyntaxFile = %SyntaxFile%`ntoken:
  132.  
  133.       StringReplace, ReadLine, A_LoopReadLine, %A_Space%, _, A
  134.       SyntaxFile := SyntaxFile " " ReadLine
  135.       ;SyntaxFile := SyntaxFile " {" ReadLine "}"
  136.  
  137.       CommandCount++
  138.       If CommandCount > 4
  139.          CommandCount = 0
  140.    }
  141.  
  142.    ; Last line
  143.    SyntaxFile = %SyntaxFile%`n`n#===========================================================
  144.  
  145.    ; Delete old syntax-file
  146.    FileDelete, %medpath%\med-syn\AutoHotkey.syn
  147.    FileDelete, %medpathroot%\med\profile_skeleton\med-syn\AutoHotkey.syn
  148.    ; Write new syntax-file
  149.    FileAppend, %SyntaxFile%, %medpath%\med-syn\AutoHotkey.syn
  150.    FileAppend, %SyntaxFile%, %medpathroot%\med\profile_skeleton\med-syn\AutoHotkey.syn
  151.  
  152.    ; Read the header for the TextLib-file
  153.    FileRead, LibFile, MEDMclHeader.txt
  154.  
  155.    Loop, Read, ..\Syntax\Commands.txt
  156.    {
  157.       StringReplace, ReadLine, A_LoopReadLine, ``n, `n , A
  158.       StringReplace, ReadLine, ReadLine, ``t, % "   ", A
  159.       StringGetPos, Pos, ReadLine, %A_Space%
  160.       StringLeft, CommandOnly, ReadLine, %Pos%
  161.  
  162.       IfInString, ReadLine, If Var = Value
  163.          CommandOnly = If =
  164.       IfInString, ReadLine, If Var [not] between
  165.          CommandOnly = If between
  166.       IfInString, ReadLine, If Var [not] contains
  167.          CommandOnly = If contains
  168.       IfInString, ReadLine, If Var [not] in
  169.          CommandOnly = If in
  170.       IfInString, ReadLine, If Var is [not] type
  171.          CommandOnly = If is type
  172.       IfInString, ReadLine, Loop`, FilePattern
  173.          CommandOnly = Loop FilePattern
  174.       IfInString, ReadLine, Loop`, Parse
  175.          CommandOnly = Loop Parse
  176.       IfInString, ReadLine, Loop`, Read
  177.          CommandOnly = Loop Read
  178.       IfInString, ReadLine, Loop`, Reg
  179.          CommandOnly = Loop Reg
  180.  
  181.       StringReplace, CommandOnly, CommandOnly, `,,
  182.       If CommandOnly =
  183.          continue
  184.       LibFile := LibFile "`n!TEXT=" CommandOnly "`n" ReadLine "`n!"
  185.    }
  186.  
  187.    ; Delete old TextLib-file
  188.    FileDelete, %medpath%\med-mcl\AutoHotkey.mcl
  189.    FileDelete, %medpathroot%\med\profile_skeleton\med-mcl\AutoHotkey.mcl
  190.    ; Write new TextLib-file
  191.    FileAppend, %LibFile%, %medpath%\med-mcl\AutoHotkey.mcl
  192.    FileAppend, %LibFile%, %medpathroot%\med\profile_skeleton\med-mcl\AutoHotkey.mcl
  193.  
  194.    ; Set 'Edit Script' to MED
  195.    RegWrite, REG_SZ,HKEY_CLASSES_ROOT,AutoHotkeyScript\Shell\Edit\Command,, %medpathroot%\med.exe "`%1"
  196.    MsgBox, 64,, %lng_installed%
  197. }
  198. else
  199. {
  200.    MsgBox, 16,, %lng_noMed%
  201. }
  202.  
  203.